package com.lp.business.model;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.iframework.support.spring.hibernate.model.BaseHibernateModelSupport;

import com.lp.business.enums.MenuType;

/**
 * 系统菜单模型
 * 
 * @author lp
 * 
 */
@Entity
@Table(name = "menu")
@org.hibernate.annotations.Table(appliesTo = "menu", comment = "系统菜单信息模型")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class Menu extends BaseHibernateModelSupport {
	private static final long serialVersionUID = -7626707213960303318L;
	/**
	 * 标签名
	 */
	@Column(columnDefinition = "varchar(128) comment '标签名'")
	private String tagName;

	/**
	 * 菜单名称
	 */
	@Column(columnDefinition = "varchar(32) comment '菜单名称'")
	private String menuName;

	/**
	 * 菜单类型
	 */
	@Enumerated(EnumType.STRING)
	@Column(columnDefinition = "varchar(32) default 'INTERNAL' not null comment '菜单类型'")
	private MenuType menuType;

	/**
	 * 图标样式
	 */
	@Column(columnDefinition = "varchar(128) comment '图标样式'")
	private String menuIconCss;

	/**
	 * 父级菜单ID
	 */
	@Column(columnDefinition = "varchar(32) comment '父级菜单ID'")
	private String menuId;

	/**
	 * 菜单等级
	 */
	@Column(columnDefinition = "int(1) default 0 not null comment '菜单等级'")
	private Integer level;

	/**
	 * 菜单请求地址
	 */
	@Column(columnDefinition = "varchar(256) comment '菜单请求地址'")
	private String menuPath;

	/**
	 * 排序
	 */
	@Column(columnDefinition = "varchar(64) comment '排序'")
	private String sort;

	/**
	 * 所属菜单
	 */
	@ManyToOne(cascade = { CascadeType.MERGE }, fetch = FetchType.LAZY)
	@JoinColumn(name = "menuId", nullable = true, insertable = false, updatable = false)
	private Menu menu;

	/**
	 * 所属的方法集合
	 */
	@OneToMany(mappedBy = "menu", cascade = { CascadeType.MERGE, CascadeType.REMOVE }, fetch = FetchType.LAZY)
	private List<MenuMethod> menuMethods;

	/**
	 * 菜单备注
	 */
	@Column(length = 128)
	private String remark;

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public MenuType getMenuType() {
		return menuType;
	}

	public void setMenuType(MenuType menuType) {
		this.menuType = menuType;
	}

	public String getMenuIconCss() {
		return menuIconCss;
	}

	public void setMenuIconCss(String menuIconCss) {
		this.menuIconCss = menuIconCss;
	}

	public String getMenuName() {
		return menuName;
	}

	public void setMenuName(String menuName) {
		this.menuName = menuName;
	}

	public Integer getLevel() {
		return level;
	}

	public void setLevel(Integer level) {
		this.level = level;
	}

	public String getMenuPath() {
		return menuPath;
	}

	public void setMenuPath(String menuPath) {
		this.menuPath = menuPath;
	}

	public String getSort() {
		return sort;
	}

	public void setSort(String sort) {
		this.sort = sort;
	}

	public void setTagName(String tagName) {
		this.tagName = tagName;
	}

	public String getTagName() {
		return tagName;
	}

	public String getMenuId() {
		return menuId;
	}

	public void setMenuId(String menuId) {
		this.menuId = menuId;
	}

	public Menu getMenu() {
		return menu;
	}

	public void setMenu(Menu menu) {
		this.menu = menu;
	}

	public List<MenuMethod> getMenuMethods() {
		return menuMethods;
	}

	public void setMenuMethods(List<MenuMethod> menuMethods) {
		this.menuMethods = menuMethods;
	}

}
